/*
 * Copyright 2011 Niklas Kyster Rasmussen
 * 
 * This file is part of WotXP.
 *
 * WotXP is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * WotXP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with WotXP; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

package net.nikr.wot.gui;

import net.nikr.wot.gui.data.Left;
import ca.odell.glazedlists.GlazedLists;
import ca.odell.glazedlists.gui.AdvancedTableFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;


public class LeftTableFormat implements AdvancedTableFormat<Left> {

	List<String> columnNames = new ArrayList<String>();

	public LeftTableFormat() {
		columnNames.add("To 100%");
		columnNames.add("Primary");
		columnNames.add("Secondary 1");
		columnNames.add("Secondary 2");
		columnNames.add("Secondary 3");
	}
	
	@Override
	public int getColumnCount() {
		return columnNames.size();
	}

	@Override
	public String getColumnName(int column) {
		return columnNames.get(column);
	}

	@Override
	public Object getColumnValue(Left baseObject, int column) {
		if (column == 0) return baseObject.getRowName();
		if (column == 1) return baseObject.getPrimary();
		if (column == 2) return baseObject.getSecondary1();
		if (column == 3) return baseObject.getSecondary2();
		if (column == 4) return baseObject.getSecondary3();
		return new Object();
	}

	@Override
	public Class getColumnClass(int column) {
		if (column == 0) return String.class;
		if (column == 1) return Integer.class;
		if (column == 2) return Integer.class;
		if (column == 3) return Integer.class;
		if (column == 4) return Integer.class;
		return Object.class;
	}

	@Override
	public Comparator getColumnComparator(int column) {
		return GlazedLists.comparableComparator();
	}
	
}
